package com.loit.business.config;

import com.baomidou.mybatisplus.annotation.DbType;
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class MybatisPlusConfig{

    @Bean
    public MybatisPlusInterceptor mybatisPlusInterceptor() {
        //  插件
        MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
        // 分页插件
        PaginationInnerInterceptor paginationInnerInterceptor = new PaginationInnerInterceptor();
        // 设置最大分页数
        paginationInnerInterceptor.setMaxLimit(100L);
        // 是否对超过最大分页时做溢出处理
        paginationInnerInterceptor.setOverflow(true);
        // 设置数据库类型
        paginationInnerInterceptor.setDbType(DbType.MYSQL);
        //paginationInnerInterceptor.setProperties();
        // paginationInnerInterceptor.setDialect();
        //paginationInnerInterceptor.setOptimizeJoin();
        // 添加分页插件
        interceptor.addInnerInterceptor(paginationInnerInterceptor);
        return interceptor;
    }


}
